package com.vivi.feverdiagnose.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DBHandler extends SQLiteOpenHelper {
	
	private static final String DATABASE_NAME = "db_servicepakar.db";
	private static final int DATABASE_VERSION = 1;
	
	//variabel tabel penyakit
	public static final String TABLE_PENYAKIT = "tb_penyakit";
	public static final String COLUMN_ID_PENYAKIT = "id_pnykt";
	public static final String COLUMN_NAMA_PENYAKIT = "nama_pnykt";
	public static final String COLUMN_SARAN = "saran";
	
	//variabel tabel gejala 
	public static final String TABLE_GEJALA = "tb_gejala_penyakit";
	public static final String COLUMN_ID_GEJALA = "id_gjl";
	public static final String COLUMN_NAMA_GEJALA = "nama_gjl";
	
	//variabel tabel rule
	//public static final String TABLE_DETAIL = "tb_detail_penyakit";
	//public static final String COLUMN_ID_DETAIL = "id_detail";
	//public static final String COLUMN_ID_PENYAKIT1 = "id_pnykt";
	//public static final String COLUMN_ID_GEJALA1 = "id_gjl";
	
	
	
	
	//query create tb_penyakit
	static final String CREATE_TB_PENYAKIT = 
		"CREATE TABLE "+TABLE_PENYAKIT+" ("
			+COLUMN_ID_PENYAKIT+" INTEGER PRIMARY KEY  NOT NULL , "
			+COLUMN_NAMA_PENYAKIT+" VARCHAR, "
			+COLUMN_SARAN+" TEXT)";

	//query create tb_gejala
	static final String CREATE_TB_GEJALA_PENYAKIT = 
		"CREATE TABLE "+TABLE_GEJALA+" ("
			+COLUMN_ID_GEJALA+" INTEGER PRIMARY KEY  NOT NULL , "
			+COLUMN_NAMA_GEJALA+" VARCHAR)";
		
	//query create tb_rule
	//static final String CREATE_TB_DETAIL_PENYAKIT = 
		//"CREATE TABLE "+TABLE_DETAIL+" ("
			//+COLUMN_ID_DETAIL+" INTEGER PRIMARY KEY  NOT NULL , "
			//+COLUMN_ID_PENYAKIT+" INTEGER, "
			//+COLUMN_ID_GEJALA+" INTEGER)";
	
			
	public DBHandler(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		// TODO Auto-generated method stub
		db.execSQL(CREATE_TB_PENYAKIT);
		//db.execSQL(CREATE_TB_DETAIL_PENYAKIT);
		db.execSQL(CREATE_TB_GEJALA_PENYAKIT);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO Auto-generated method stub
		db.execSQL("DROP TABLE IF EXISTS "+TABLE_PENYAKIT);
		//db.execSQL("DROP TABLE IF EXISTS "+TABLE_DETAIL);
		db.execSQL("DROP TABLE IF EXISTS "+TABLE_GEJALA);
		onCreate(db);
	}

}
